import moment from '@/utils/moment'
import Model from "./Model"
import calc from '@/utils/calc.js'

class CouponInfoModel extends Model {
	constructor () {
		super()
		this.id = ''
		this.name = ''
		this.member_id = ''
		this.amount = 0
		this.status = 0
		this.created_at = 0
		this.updated_at = 0
		this.expire_time = 0
		this.discount_card_id = 0
		this.min_order_amount = 0
		this.time_status = 0
		this.for_user = 0
		this.strategy_name = ''
	}
	
	//  字段过滤
	fields() {
		const fields = super.fields()
		
		// fields['amount'] = () => {
		// 	return calc.Div(this.amount, 100)
		// }
		
		if (moment().isAfter(this.expire_time * 1000)) {
			fields['status'] = () => {
				return -1
			}
		}
		
		return fields
	}

}
    
export default CouponInfoModel